<?php
class jenis_member extends MY_Controller{
    function jenis_member(){
        parent::MY_Controller();
        $this->data['title'] = "Master Data Jenis Member";
        $this->load->model('m_jenis_member');
    }
    function index(){
        $this->data['content'] = "jenis_member/v_jenis_member";
        $this->data['listJenisMember'] = $this->m_jenis_member->getListJenisMember();
        $this->render($this->data);
    }
    function add_jenis_member_form(){
        $this->data['content'] = "jenis_member/v_jenis_member";
        $this->data['subLink'] = "jenis_member/add_jenis_member_proses";
        $this->data['formTitle'] = "Form Tambah Data Jenis Member";
        $this->data['formView'] = "jenis_member/addJenisMemberForm";
        $this->data['listJenisMember'] = $this->m_jenis_member->getListJenisMember();
        $this->render($this->data);
    }
    function edit_jenis_member_form($id){
        $this->data['content'] = "jenis_member/v_jenis_member";
        $this->data['subLink'] = "jenis_member/edit_jenis_member_proses";
        $this->data['formTitle'] = "Form Edit Data Jenis Member";
        $this->data['formView'] = "jenis_member/editJenisMemberForm";
        $this->data['dataInput'] = $this->m_jenis_member->getJenisMemberById($id);
        $this->data['listJenisMember'] = $this->m_jenis_member->getListJenisMember();
        $this->render($this->data);
    }
    function add_jenis_member_proses(){
        $data = array('nama' => $this->input->post('nama'),
            'keterangan' => $this->input->post('keterangan'));
        $insert = $this->m_jenis_member->addJenisMember($data);
        if($insert == TRUE){
            $this->session->set_flashdata("message",1);
        }else{
            $this->session->set_flashdata("message",2);
        }
        
        redirect("jenis_member");
    }
    function edit_jenis_member_proses(){
        $data = array('id' => $this->input->post('id'),
            'nama' => $this->input->post('nama'),
            'keterangan' => $this->input->post('keterangan'));
        $update = $this->m_jenis_member->editJenisMember($data);
        if($update == TRUE){
            $this->session->set_flashdata("message",1);
        }else{
            $this->session->set_flashdata("message",2);
        }
        
        redirect("jenis_member");
    }
    function delete_jenis_member($id){
        $delete = $this->m_jenis_member->deleteJenisMember($id);
        if($delete == TRUE){
            $this->session->set_flashdata("message",3);
        }else{
            $this->session->set_flashdata("message",4);
        }
        
        redirect("jenis_member");
    }
}
?>
